
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>1、Servlet基础知识 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>1、Servlet基础知识 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">什么是Servlet？它的核心用途是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Servlet是Java平台上的一种用于开发Web应用程序的组件，它是基于Java技术的服务器端程序。其核心用途是处理客户端发起的HTTP请求并生成相应的HTTP响应。</div>
          </div>
          <div class="card-source">来源: 什么是Servlet</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">文档中提到了Servlet的哪五个主要特点或优势？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">文档中提到的五个主要特点和优势是：跨平台性、灵活性、安全性、高性能和可扩展性。</div>
          </div>
          <div class="card-source">来源: 什么是Servlet</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Servlet的生命周期包含哪四个主要阶段？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Servlet的生命周期包括四个主要阶段：1. 加载阶段（Loading）；2. 初始化阶段（Initialization），调用init()方法；3. 请求处理阶段（Request Handling），调用service()方法；4. 销毁阶段（Destruction），调用destroy()方法。</div>
          </div>
          <div class="card-source">来源: Servlet生命周期</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在Servlet的API结构中，`HttpServlet`与`GenericServlet`有何关系？`HttpServlet`的特长是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`HttpServlet`是`GenericServlet`的子类。它的特长是专门用于处理HTTP请求和响应，并提供了如doGet()、doPost()等方法来处理不同类型的HTTP请求。</div>
          </div>
          <div class="card-source">来源: Servlet的基本结构和API</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">实现Servlet的URL映射主要有哪两种方式？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">第一种方式是在`web.xml`文件中使用`<servlet-mapping>`元素进行配置；第二种方式是使用`@WebServlet`注解，在Servlet类上直接指定URL模式。</div>
          </div>
          <div class="card-source">来源: Servlet URL映射</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">`HttpServletRequest`和`HttpServletResponse`对象在请求处理中分别扮演什么角色？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`HttpServletRequest`对象封装了客户端的HTTP请求信息，如请求方法、参数和请求头。`HttpServletResponse`对象用于生成HTTP响应并将其发送给客户端，例如设置响应状态码、添加响应头和写入响应体。</div>
          </div>
          <div class="card-source">来源: Servlet的基本结构和API</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">Cookie是什么？它通常被用来实现哪些功能？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Cookie是由Web服务器发送并存储在用户计算机（浏览器）上的小型文本文件。它通常用于跟踪用户的会话状态、记录用户的偏好设置以及实现个性化的用户体验。</div>
          </div>
          <div class="card-source">来源: Cookie</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Session机制是如何实现跨请求的状态保持的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">当用户与服务器建立会话时，服务器会为该用户创建一个唯一的会话ID，并通过Cookie或URL重写技术将其发送给客户端。在后续请求中，客户端会携带这个ID，服务器据此找到对应的Session数据，从而在不同HTTP请求之间保持状态。</div>
          </div>
          <div class="card-source">来源: Session</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">对比</div>
          <div class="card-question">Cookie和Session在数据存储位置上有何本质区别？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">对比</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">本质区别在于存储位置：Cookie的数据存储在用户的浏览器中（客户端）；而Session的数据存储在服务器端，客户端仅通过一个唯一的会话ID与之关联。</div>
          </div>
          <div class="card-source">来源: Cookie 和 Session</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
